package com.cskaoyan.mall.product.controller;

import com.cskaoyan.mall.common.result.Result;
import com.cskaoyan.mall.product.dto.TrademarkDTO;
import com.cskaoyan.mall.product.query.CategoryTrademarkParam;
import com.cskaoyan.mall.product.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Macro_Ray
 * @since 2024/6/7 下午8:42
 */
@RestController
@RequestMapping("/admin/product/baseCategoryTrademark/")
public class CateTradeController {

    @Autowired
    CategoryService categoryService;

    @GetMapping("findTrademarkList/{thirdLevelCategoryId}")
    public Result<List<TrademarkDTO>> findCateTradeList(@PathVariable("thirdLevelCategoryId") Long category3Id) {
        List<TrademarkDTO> cateTradeList = categoryService.findCateTradeListByTLCId(category3Id);
        return Result.ok(cateTradeList);
    }

    @GetMapping("findCurrentTrademarkList/{thirdLevelCategoryId}")
    public Result<List<TrademarkDTO>> findCurrentCateTradeList(@PathVariable("thirdLevelCategoryId") Long category3Id) {
        List<TrademarkDTO> cateTradeList = categoryService.findUnLinkedTradeListByTLCId(category3Id);
        return Result.ok(cateTradeList);
    }

    @PostMapping("save")
    public Result saveTrademark(@RequestBody CategoryTrademarkParam categoryTrademarkParam) {
        categoryService.saveCateTrademark(categoryTrademarkParam);
        return Result.ok();
    }

    @DeleteMapping("remove/{thirdLevelCategoryId}/{trademarkId}")
    public Result removeTrademark(@PathVariable("thirdLevelCategoryId") Long thirdLevelCategoryId,
                                   @PathVariable("trademarkId") Long trademarkId) {
        categoryService.removeCateTrademark(thirdLevelCategoryId,trademarkId);
        return Result.ok();
    }
}
